﻿using System;
using System.ServiceModel;
using System.Threading;

using Sunyi.Project.WebPoint.DataContract;
using Sunyi.Project.WebPoint.PlatFormException;

namespace Sunyi.Project.WebPoint.BusinessLogic
{
    public static class ServiceExceptionHandler
    {
        public static FaultException<WebPointServiceException> Handle(string source, Exception ex)
        {
            Log log = new Log { Level = LogLevel.Error.ToString(), Source = source };
            log.UserName = Thread.CurrentThread.Name;
            log.Data = ex.ToString();

            Logger.Write(log);

            return new FaultException<WebPointServiceException>(new WebPointServiceException(ex.Message,ex));
        }
    }
}